﻿using ElasticsearchCore.ElasticSearch.Impl;
using ElasticsearchCore.ElasticSearch.Interfaces;
using ElasticsearchCoreEs.ElasticsearchCoreElasticSearchs.Contents;
using Microsoft.Extensions.DependencyInjection;

namespace ElasticsearchCore.IOC
{
    //基础设施依赖注入
    public static class IocContainerFactory
    {
        public static void RegServices(this IServiceCollection services)
        {
            //Transient：每次从容器 （IServiceProvider）中获取的时候都是一个新的实例
            ///Singleton：每次从同根容器中（同根 IServiceProvider）获取的时候都是同一个实例
            //Scoped：每次从同一个容器中获取的实例是相同的、
            //对基础设施的依赖注入
            services.AddScoped<IAliasProvider, ElasticsearchProvider>()
                .AddScoped<IDeleteProvider, ElasticsearchProvider>()
                .AddScoped<IIndexProvider, ElasticsearchProvider>()
                .AddScoped<IContentService, ContentService>();
            //对业务的依赖注入
            services.AddScoped<IContentService, ContentService>();
        }
    }
}
